/**
 * Created by luomingzhong on 17/3/19.
 * 本段代码是实现队列的数据结构
 */
class Queue {
    constructor() {
        this.dataStore = [];
    }

    //读取队列的元素
    front() {
        return this.dataStore[0];
    }

    //读取队尾元素
    back() {
        return this.dataStore[this.dataStore.length - 1];
    }

    empty() {
        return this.dataStore.length > 0 ? false : true;
    }

    //队尾添加元素
    enqueue(element) {
        this.dataStore.push(element);
    }

    //删除队首元素
    dequeue() {
        this.dataStore.shift();
    }

    toString() {
        let retStr = "";
        for (let i = 0; i < this.dataStore.length; ++i) {
            retStr += this.dataStore[i] + "\n";
            return retStr;
        }
    }

}
myQue = new Queue();
myQue.enqueue('xx');
console.log(myQue.front());
module.exports = Queue;

